package com.imooc.player;

import java.io.Serializable;

/**
 * 歌曲类
 * @author Administrator
 *
 */
public class Song implements Serializable{
	private String id;//歌曲编号
	private String name;//歌曲名称
	private String singer;//歌曲歌唱者
//	无参构造
	public Song(){
		
	}
//	带参构造
	public Song(String id, String name, String singer) {
		super();
		this.setId(id);
		this.setName(name);
		this.setSinger(singer);
	}
//	set和get方法
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSinger() {
		return singer;
	}
	public void setSinger(String singer) {
		this.singer = singer;
	}
//	重写toString方法
	@Override
	public String toString() {
		return "歌曲id" + id + ", 歌曲名称：" + name + ", 演唱者：" + singer;
	}
//	重写hashcode方法
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((singer == null) ? 0 : singer.hashCode());
		return result;
	}
//	重写equals方法
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj.getClass()==Song.class){
			Song song=(Song)obj;
			return song.getId().equals(id)&&song.getName().equals(name)&&song.getSinger().equals(singer);
		}
		return false;
		
	}
	
	
}
